﻿<div class="layui-card" id="lg-ExamTemplateEdit">
    <div class="layui-card-header">
        <i class="fa fa-home fa-fw"></i>编辑准考证模板
        <div class="f-r">
            <button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="back()"><i class="fa fa-mail-reply fa-fw"></i>返回</button>
        </div>
    </div>
    <div class="layui-card-body" id="">
        <div class="layui-form-item">
            <form class="layui-form layui-form-pane" action="" id="fm_EditExamTemplate" lay-filter="fm_EditExamTemplate">
                <div class="layui-form-item hide">
                    <label class="layui-form-label"><i style="color:#f00">*</i>Id</label>
                    <div class="layui-input-block">
                        <input type="text" name="Id" class="layui-input" readonly lay-verify="required" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i style="color:#f00">*</i>模板名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="Title" class="layui-input" placeholder="填写模板名称" lay-verify="required" />
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">模板简介</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" class="layui-textarea" name="Tips"></textarea>
                    </div>
                </div>
                <div class="layui-form-item" pane>
                    <label class="layui-form-label">是否启用</label>
                    <div class="layui-input-block">
                        <input type="checkbox" checked="" value="1" name="IsUsing" lay-skin="switch" lay-filter="IsUsing" lay-text="ON|OFF">
                    </div>
                </div>
                <div class="layui-form-item">
                    <blockquote class="layui-elem-quote layui-text">
                        <p>参数：</p>
                        <p>计划名称：{@@JH} 考试名称：{@@KS} 考场：{@@KC} 序号：{@@SN} 准考证号：{@@ZKZH} 年级：{@@NJ}</p>
                    </blockquote>
                </div>
                <div class="layui-form-item layui-form-text" style="">
                    <label class="layui-form-label">模板详情</label>
                    <div class="layui-input-block" style="padding: 10px; border: 1px solid rgb(240, 240, 240);">
                        <textarea id="editor" name="Text" style="height: 400px;"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="bt_EditExamTemplate">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
        <!-- 内容主体区域结束 -->
    </div>
</div>

<script>
    frame.createPage({
        data: {
            examtemp:null,
        },
        mounted: function() {
            this.GetExamTemplate();
        },
        methods: {
            GetExamTemplate: function() {
                lg.request({
                    url: "/api/sys/apply/GetExamTemplate",
                    data: { id:@ViewBag.id},
                    success: res => {
                        if (res.code == 0 && res.data != null) {
                            this.examtemp = res.data;
                            this.FormRander(); 
                            this.VueRander();
                        } else {
                            layer.msg("数据获取异常！", {icon:2})
                        }
                    }
               })
            },
            FormRander: function() {
                var page = this;
                layui.use(['form', 'laydate'], function() {
                    var form = layui.form
                        , laydate = layui.laydate;
                    form.render();
                    form.val("fm_EditExamTemplate", page.examtemp);
                    editor.render("editor");
                    form.on('submit(bt_EditExamTemplate)', function(d) {
                        var data = d.field;
                        if (!data.IsUsing) {
                            data.IsUsing = 0
                        }
                        lg.request({
                            url: "/api/sys/apply/EditExamTemplate",
                            method: "post",
                            data: data,
                            success: res => {
                                if (res.code == 0) {
                                    layer.msg("编辑成功！", { icon: 1 });
                                    page.vm.back();
                                } else {
                                    layer.msg(res.msg, { icon: 2 })
                                }
                            }
                        })
                        return false;
                    })
                })
            },
            VueRander: function() {
                var page = this;
                page.vm = Vue.createApp({
                    data() {
                        return {
                           
                        }
                    },
                    mounted: function() {
                        
                    },
                    methods: {
                        back: function() {
                            frame.Back(page.url, res => {
                                res.laytable.reload()
                            })
                        },
                    }
                }).mount("#lg-ExamTemplateEdit")
            }
        },
    }).mount();
</script>